<template>
	<div class="content">
		<Collapse v-model="value1">
			<Panel name="1">
				释放配置
				<p slot="content">
					<Form label-position="right" :label-width="100">
						<div class="canshu">
							<FormItem label="VIP节点：">
								<!-- <Input class="w80" v-model="value2" @on-change="oninput" /> -->
								<input  class="w80 ipt" v-model="value2" @input="oninput"> %
                                <Button type="primary" size="large" v-on:click="btn2">保　存</Button>
							</FormItem>
						</div>
					</Form>
				</p>

				<p slot="content">
					<Form label-position="right" :label-width="100">
						<div class="canshu">
							<FormItem label="超级节点：">
								<!-- <Input class="w80" v-model="value3" /> -->
								<input  class="w80 ipt" v-model="value3" @input="oninput2"> %
                                <Button type="primary" size="large" v-on:click="btn3">保　存</Button>
							</FormItem>
						</div>
					</Form>
				</p>
				<!-- <input type="number" class="mui-input-clear" v-model="sum" @input="oninput" placeholder="请输入金额"> -->
			</Panel>
		</Collapse>
	</div>
</template>

<script>
export default {
  data () {
    return {
      value1: '1', // 默认展开第一个列表
      value2: '',
      value3: '',
      sum: ''
    }
  },
  created () {

  },
  mounted () {
    this.$Message.config({
      top: 250
    })

    this.axios.get('/admin/settings/release_configs').then(res => {
      if (res.data.code == 200) {
        this.value2 = res.data.data[0].ratio
        this.value3 = res.data.data[1].ratio
      } else if (res.data.code == 500) {

      }
    })
  },
  methods: {

    // 处理时间段时间格式
    getTime (daterange) {
      this.dataValue = daterange
    },
    btn2 () {
      let params = this.qs.stringify({
        type: 1,
        ratio: this.value2
      })
      this.axios.put('/admin/settings/release_configs', params).then(res => {
        if (res.data.code == 200) {
          this.$Message.info(res.data.msg)
          // this.modal1 = false;
          // this.getConfig();
        }
      }).catch(err => {
        this.$Message.info('系统错误')
      })
    },
    btn3 () {
      let params = this.qs.stringify({
        type: 2,
        ratio: this.value3
      })
      this.axios.put('/admin/settings/release_configs', params).then(res => {
        if (res.data.code == 200) {
          this.$Message.info(res.data.msg)
          // this.modal1 = false;
          // this.getConfig();
        }
      }).catch(err => {
        this.$Message.info('系统错误')
      })
    },
    oninput (e) {
      e.target.value = (e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || null
      this.value2 = e.target.value
    },
    oninput2 (e) {
      e.target.value = (e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || null
      this.value3 = e.target.value
    }

  }
}
</script>

<style lang="less" scoped>
	.p-10 {
		padding-top: 0 !important;
		padding-left: 50px !important;
	}

	.w50 {
		width: 50px !important;
	}

	.w25 {
		width: 25px !important;
	}

	.w120 {
		width: 120px !important;
	}

	.mar {
		margin-left: 5px;
	}

	.pl-100 {
		padding-left: 100px;
	}

	.visibility {
		visibility: hidden;
	}
	.ipt{
		display: inline-block;
    width: 100%;
    height: 32px;
    line-height: 1.5;
    padding: 4px 7px;
    font-size: 12px;
    border: 1px solid #dcdee2;
    border-radius: 4px;
    color: #515a6e;
    background-color: #fff;
    background-image: none;
    position: relative;
}

</style>
